function setIsFree() {
    if (isFree === 1) {
        isFree = 0;
    } else {
        isFree = 1;
        levelId = 0;
    }
    jumpPage(0);
}
function setIsVip() {
    if (levelId === 1) {
        levelId = 0;
    } else {
        levelId = 1;
        isFree = 0;
    }
    jumpPage(0);
}
function setOrderBy(value) {
    orderBy = value;
    jumpPage(0);
}
function jumpPage(page) {
    var url = '/picture/list.html?categoryId=' + categoryId;
    if (albumId > 0) {
        url += '&albumId=' + albumId;
    }
    if (isFree > 0) {
        url += '&isFree=' + isFree;
    }
    if (levelId > 0) {
        url += '&levelId=' + levelId;
    }
    if (orderBy > 0) {
        url += '&orderBy=' + orderBy;
    }
    if (page > 0) {
        url += '&page=' + page;
    }
    location.href = url;
}

function downPicture(id) {
    if (userId < 1) {
        return layer.msg("此功能需要登录后方可操作，登录跳转中，请稍后...", {time: 1000}, function () {
            location.href = "/auth/login.html";
        });
    }
    $.get("/picture/download.json?id=" + id, function (json) {
        if (json.code === 0) {
            downloadImg(json.data, title)
            // window.location.replace(json.msg);
        } else if (json.code === 403) {
            buyMember(1);
        } else {
            return layer.msg(json.msg);
        }
    })
}
function downloadImg(url, name) {
    var x = new XMLHttpRequest();
    x.open("GET", url, true);
    x.responseType = 'blob';
    x.onload = function (e) {
        var url = window.URL.createObjectURL(x.response)
        var a = document.createElement('a');
        a.href = url;
        a.download = name.indexOf(".") < 1 ? name + ".jpg" : name;
        a.click();
    }
    x.send();
}
//鼠标经过专集滚动图片
$('.list-album-img-box').mouseenter(function () {
    $(this).addClass('scroll-box');
}).mouseleave(function () {
    $(this).removeClass('scroll-box');
});
//滑动页面顶部出现下载按钮
$(window).scroll(function () {
    if($(document).scrollTop() >= 150){
        $('.detail-float-header').show();
    }else {
        $('.detail-float-header').hide();
    }
});